home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-07 | 6.6 KB | 247 lines | [TEXT/CWIE] |
- // Release Version: $ ODF 1 $
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- //=======================================================================
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k" // command numbers
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWCONTXT_H
- #include "FWContxt.h" // FW_CViewContext
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h" //::FW_About()
- #endif
-
- #include "FWClpCmd.h" // FW_CClipboardCommand
-
- // ----- OS Layer -----
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h" // FW_CSharedLibraryResourceFile, FW_gInstance
- #endif
-
- #ifndef FWMENU_H
- #include "FWMenu.h" // FW_CMenuBar, etc.
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h" // FW_CMenuEvent, FW_CMouseEvent
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h" // FW_CRectShape
- #endif
-
- #ifndef FWPICSHP_H
- #include "FWPicShp.h" // FW_PPicture, FW_CPictureShape
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h" // FW_CRoundRectShape
- #endif
-
- #ifndef FWCMD_H
- #include "FWCmd.h" // FW_CCommand
- #endif
-
- #ifndef FWDRCMD_H
- #include "FWDrCmd.h"
- #endif
-
- // ----- OpenDoc Includes -----
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh> // ODDragItemIterator
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh> // ODTranslation
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh> // ODSession
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh> // kODPropContents
- #endif
-
- //========================================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment Talker
- #endif
-
- FW_DEFINE_AUTO(CTalkerFrame)
-
- //========================================================================================
- CTalkerFrame::CTalkerFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, CTalkerContent* content)
- : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
- FW_MDroppableFrame(ev, this),
- fTalkerContent(content),
- fPictShape(NULL)
- {
- this->MyInitPicture(ev);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- void
- CTalkerFrame::MyInitPicture(Environment* ev)
- {
- FW_CSharedLibraryResourceFile resFile(ev); // PICT resource in shared library
- const short kPizzaPictID = 2000;
- FW_CPicture picture(resFile, kPizzaPictID);
- fFrameRect = this->GetBounds(ev); // Get new Frame Rect
- fPictShape = FW_NEW(FW_CPictureShape, (picture, fFrameRect));
- }
-
- //----------------------------------------------------------------------------------------
- CTalkerFrame::~CTalkerFrame()
- {
- FW_START_DESTRUCTOR
- delete fPictShape;
- }
-
- //----------------------------------------------------------------------------------------
- void
- CTalkerFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- FW_CViewContext context(ev, this, odFacet, invalidShape);
-
- // erse invalid shape
- FW_CRect invalidRect;
- context.GetClipRect(invalidRect);
- FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kWhiteEraseInk);
- // draw the picture
- fPictShape->Render(context);
- // draw a frame around it
- FW_CRoundRectShape::RenderRoundRect(context,
- fFrameRect,
- FW_CPoint(FW_IntToFixed(30), FW_IntToFixed(30)),
- FW_kFrame,
- FW_CInk(FW_kRGBBlue));
- }
-
- //----------------------------------------------------------------------------------------
- void
- CTalkerFrame::FrameShapeChanged(Environment* ev)
- {
- FW_CFrame::FrameShapeChanged(ev);
- fFrameRect = this->GetBounds(ev); // Get new frame rect
- // modify picture
- FW_CPicture picture = fPictShape->GetPicture();
- fPictShape->SetGeometry(picture, fFrameRect);
- // force redraw of whole frame
- this->Invalidate(ev, fFrameRect);
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CTalkerFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus,
- FW_Boolean isRoot) // Override
- {
- if (hasMenuFocus) {
- FW_Boolean hasRightProperty = FALSE;
- hasRightProperty = this->HasPropertyOnClipboard(ev, kODPropContents, FW_CPart::gMacTEXTDataType);
- menuBar->EnableCommand(ev, kODCommandPaste, hasRightProperty);
- menuBar->EnableCommand(ev, cFasterCmd, TRUE);
- menuBar->EnableCommand(ev, cSlowerCmd, TRUE);
- }
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CTalkerFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = TRUE;
- CTalkerCommand* cmd = NULL;
- switch (theMenuEvent.GetCommandID(ev)) {
- case kODCommandAbout:
- ::FW_About(ev, this->GetPart(ev), kAbout);
- break;
-
- case cFasterCmd:
- cmd = FW_NEW(CTalkerCommand, (ev, cFasterCmd, this,
- fTalkerContent->MyGetTalker()));
- cmd->Execute(ev);
- break;
-
- case cSlowerCmd:
- cmd = FW_NEW(CTalkerCommand, (ev, cSlowerCmd, this,
- fTalkerContent->MyGetTalker()));
- cmd->Execute(ev);
- break;
-
- default:
- menuHandled = FALSE;
- }
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CTalkerFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_UNUSED(ev);
- FW_Boolean handledEvent = FALSE;
- if (theMouseEvent.GetNumberOfClicks(ev) == 2) {
- fTalkerContent->MySayText(ev);
- handledEvent = TRUE;
- }
- return handledEvent;
- }
-
- //----------------------------------------------------------------------------------------
- ODDragResult
- CTalkerFrame::CanAcceptDrop(Environment* ev, ODDragItemIterator* dragInfo)
- {
- ODDragResult result = FW_MDroppableFrame::CanAcceptDrop(ev, dragInfo);
-
- if (!result) {
- ODStorageUnit *dragSU;
- for (dragSU = dragInfo->First(ev); dragSU; dragSU = dragInfo->Next(ev))
- if (dragSU->Exists(ev, kODPropContents, FW_CPart::gMacTEXTDataType, 0)) // 'TEXT' in Scrap
- return TRUE;
- }
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- FW_CDropCommand*
- CTalkerFrame::NewDropCommand(Environment *ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint)
- {
- return FW_NEW(FW_CDropCommand, (ev, frame, dropInfo, facet, dropPoint, !FW_kCanUndo) );
- }
-
- //----------------------------------------------------------------------------------------
- FW_CClipboardCommand*
- CTalkerFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(FW_CClipboardCommand,
- (ev, commandID, this, ! FW_kCanUndo) );
- }
-
-